var ad = null, adt = null;

Page({
    data: {},
    onLoad: function(t) {
      if(wx.createRewardedVideoAd){
        (ad = wx.createRewardedVideoAd({adUnitId: "adunit-5cc17a25e4c5cb68"})).onLoad(function() {}),
        ad.onError(function(n) {}), 
        ad.onClose(function(n) {})
      }
      if(ad){
        ad.show().catch(function() {
        ad.load().then(function() {
            return ad.show();
          }).catch(function(n) {
              console.log("激励视频 广告显示失败");
          });
        })
      }
      if(wx.createInterstitialAd){
        (adt = wx.createInterstitialAd({adUnitId: "adunit-5cc17a25e4c5cb68"})).onLoad(function() {}),
        adt.onError(function(n) {}), 
        adt.onClose(function() {})
      }
      if(adt){
        adt.show().catch(function(n) {
          console.error(n);
        });
      }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});